package com.jlpay.openapi.demo.trans.refunds;

import com.jlpay.open.jlpay.sdk.java.model.trans.refunds.request.RefundsRequest;
import com.jlpay.open.jlpay.sdk.java.model.trans.refunds.response.RefundsResponse;
import com.jlpay.open.jlpay.sdk.java.utils.json.JsonUtils;
import com.jlpay.openapi.demo.JlpayOpenApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 异步退款申请
 *
 * @author zhangyongfeng
 * @date 2025/3/18
 */
public class RefundsService {

    private static final Logger LOGGER = LoggerFactory.getLogger(RefundsService.class);

    public static void main(String[] args) {
        RefundsRequest request = buildRefundsRequest();
        RefundsResponse response = JlpayOpenApiService.openMerchService()
                .post(request, RefundsResponse.class);
        LOGGER.info("退款申请响应:{}", JsonUtils.toString(response));
    }

    private static RefundsRequest buildRefundsRequest() {
        RefundsRequest request = new RefundsRequest();
        request.setMchId("849581183510017");
        request.setOutTradeNo("20250318500005Test");
        request.setOriOutTradeNo("20250318100005Test");
        request.setTotalFee("1");
        request.setRemark("退款说明");
        request.setMchCreateIp("123.12.12.123");
        request.setLongitude("116.078631");
        request.setLatitude("39.71274");
        request.setNotifyUrl("http://172.20.20.85:38001/jlpay/refunds/notify");
        return request;
    }
}
